package com.guigu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.guigu.bean.Record;
import com.guigu.bean.RecordExample;
import com.guigu.bean.RecordExample.Criteria;
import com.guigu.dao.RecordMapper;

/**
 * @author wangzibin
 *日程的CRUD
 *Service
 */
@Service
public class RecordServices {
	
	@Autowired
	RecordMapper recordMapper;
	
	/**
	 * 日期模糊查询日程
	 * @param vagueDate
	 * @return
	 */
	public List<Record> getRecordsByVagueDate(String vagueDate,int userId){
		if (vagueDate==null||userId==0) {
			return null;
		}
		RecordExample example=new RecordExample();
		Criteria criteria=example.createCriteria();
		criteria.andUsertimeVagueLike(vagueDate).andUseridEqualTo(userId);
		return recordMapper.selectByExample(example);
	}
	
	/**
	 * 日程保存
	 * @param record
	 */
	public void saveRecord (Record record ) {
		recordMapper.insertSelective(record);
	}

	/**
	 * 日程修改
	 * @param record
	 */
	public void updateRecord(Record record) {
		recordMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 日程删除
	 * @param recordid
	 */
	public void deleteByRecordId(Integer recordId) {
		recordMapper.deleteByPrimaryKey(recordId);
	}
}
